
export dapr_version=$(
  curl -sL \
    https://api.github.com/repos/dapr/dapr/releases/latest |
    jq -r '.tag_name | ltrimstr("v")'
)
export dashboard_version=$(
   curl -sL \
    https://api.github.com/repos/dapr/dashboard/releases/latest |
    jq -r '.tag_name | ltrimstr("v")'
)

echo "dapr: ${dapr_version}"
echo "dapr_dashboard: ${dashboard_version}"

export dapr="dapr-${dapr_version}.tgz"
export dapr_dashboard="dapr-dashboard-${dashboard_version}.tgz"
export proxy="https://ghproxy.net/"
export namespace="dapr-system"
wget ${proxy}https://raw.githubusercontent.com/dapr/helm-charts/refs/heads/master/${dapr}
wget ${proxy}https://raw.githubusercontent.com/dapr/helm-charts/refs/heads/master/${dapr_dashboard}

helm upgrade --create-namespace --install dapr -n ${namespace} ${dapr} --set dapr_scheduler.cluster.storageSize=16Gi #--set global.registry="ghcr.nju.edu.cn/dapr"
helm upgrade --create-namespace --install dapr-dashboard -n ${namespace} ${dapr_dashboard} --values ingress-values.yaml

rm -rf ${dapr}
rm -rf ${dapr_dashboard}
